import Vue from 'vue'
import Router from 'vue-router'
import constantRoutes from './routes'

Vue.use(Router)

const createRouter = () => new Router({
  // 路由组件跳转时 页面保持最顶端
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
